<template>
  <div class="MessageArea-comment">
    <div class="comment-header">
      <h2>
        <span>{{ title }}</span>
        <span>({{ total }})</span>
      </h2>
    </div>
    <div class="comment-body">
      <ul>
        <li v-for="userComment in list" :key="userComment.id">
          <div class="comment-avatar">
            <Avatar :url="userComment.avatar" :size="50" />
          </div>
          <div class="comment-content">
            <div>
              <div class="comment-username">{{ userComment.nickname }}</div>
              <span class="comment-time">{{ userComment.date }}</span>
            </div>
            <div class="comment-text">
              {{ userComment.content }}
            </div>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import Avatar from "@/components/Avatar";
export default {
  props: {
    title: {
      type: String,
      default: "",
    },
    total: {
      type: Number,
      default: 0,
    },
    list: {
      type: Array,
      default: () => [],
    },
  },
  components: {
    Avatar,
  },
};
</script>
<style lang="less" scoped>
@import "~@/styles/var.less";
.comment-header {
  span:nth-child(1) {
    margin-right: 15px;
  }
}
.comment-body {
  ul li {
    display: flex;
    padding: 18px 0;
    border-bottom: 1px solid @gray;
    position: relative;
    .comment-avatar {
      padding: 7px 0 0px 5px;
      margin-top: 2px;
    }
    .comment-content {
      margin-left: 8px;
      padding-bottom: 12px;
      .comment-username {
        padding: 8px 0;
        font-size: 20px;
        line-height: 100%;
        height: 40px;
        box-sizing: border-box;
        color: lighten(@success, 10%);
      }
      .comment-time {
        position: absolute;
        top: 37px;
        right: 0.85em;
        color: darken(@gray, 20%);
        font-size: 10px;
      }
    }
  }
}
</style>